﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace HDF5
{

    using hid_t = System.Int32;
    using herr_t = System.Int32;
    using hsize_t = System.UInt64;
    using hssize_t = System.Int64;
    using hunsigned = System.UInt32;

    using hbool_t = System.UInt32;
    using htri_t = System.Int32;
    using sszie_t = System.Int64;

    using haddr_t = System.UInt64;

    using uint32_t = System.UInt32;
    using uint64_t = System.UInt64;


    /* Common iteration orders */
    public enum H5_iter_order_t
    {
        H5_ITER_UNKNOWN = -1,       /* Unknown order */
        H5_ITER_INC,                /* Increasing order */
        H5_ITER_DEC,                /* Decreasing order */
        H5_ITER_NATIVE,             /* No particular order, whatever is fastest */
        H5_ITER_N		        /* Number of iteration orders */

    }

    /*
     * The types of indices on links in groups/attributes on objects.
     * Primarily used for "<do> <foo> by index" routines and for iterating over
     * links in groups/attributes on objects.
     */
    public enum H5_index_t {
        H5_INDEX_UNKNOWN = -1,	/* Unknown index type			*/
        H5_INDEX_NAME,		/* Index on names 			*/
        H5_INDEX_CRT_ORDER,		/* Index on creation order 		*/
        H5_INDEX_N			/* Number of indices defined 		*/
    }  

    /*
     * Storage info struct used by H5O_info_t and H5F_info_t
     */
    public struct H5_ih_info_t {
        hsize_t     index_size;     /* btree and/or list */
        hsize_t     heap_size;
    } 


    public static class H5
    {

        public static int H5_VERS_MAJOR = 1;
        public static int H5_VERS_MINOR = 8;
        public static int H5_VERS_RELEASE = 5;
        public static string H5_VERS_SUBRELEASE = "patch1";

        public static string H5_VERS_INFO  =  "HDF5 library version: 1.8.5-patch1" ;

        public static int H5P_DEFAULT = 0;
        public static int H5_ITER_ERROR =  -1;
        public static int H5_ITER_CONT  =  0;
        public static int H5_ITER_STOP = 1;


        /// <summary>
        /// import HDF5 general library functions
        /// </summary>
        /// <returns></returns>
        #region HDF5 General Library Functions
        [DllImport("hdf5dll.dll",CharSet=CharSet.Ansi)]
        public static extern herr_t H5open();

        [DllImport("hdf5dll.dll",CharSet=CharSet.Ansi)]
        public static extern herr_t H5close() ;

        [DllImport("hdf5dll.dll",CharSet=CharSet.Ansi)]
        public static extern herr_t H5get_libversion(out hunsigned majnum, out hunsigned minnum, hunsigned relnum);

        [DllImport("hdf5dll.dll",CharSet=CharSet.Ansi)]
        public static extern herr_t H5check_version(hunsigned majnum, hunsigned minnum, hunsigned relnum);

        [DllImport("hdf5dll.dll",CharSet=CharSet.Ansi)]
        public static extern herr_t H5set_free_list_limits( int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim ) ;

         

        [DllImport("hdf5dll.dll",CharSet=CharSet.Ansi)]
        public static extern herr_t H5garbage_collect() ;

        [DllImport("hdf5dll.dll",CharSet=CharSet.Ansi)]
        public static extern herr_t H5dont_atexit();
        #endregion HDF5 General Library Functions
    }
}
